<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VUE Template</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <!-- <app></app>
        <hr> -->
    </div>
</body>
    <script type="text/javascript">
        Vue.config.devtools = true
        //创建student组件
        const student = Vue.extend({
            template:`
            <div>
                <h2>学生名称：{{name}}</h2>
                <h2>学生年龄：{{age}}</h2>
            </div>
            `
            ,
            data(){
                return {
                    name:'trent',
                    age:18
                }
            },
        })

        //创建school组件
        const school = Vue.extend({
            template:`
            <div>
                <h2>学校名称：{{schoolName}}</h2>
                <h2>学校地址：{{address}}</h2>
                <student></student>               
            </div>
            `
            ,
            data(){
                return {
                    schoolName:'xxx',
                    address:'南京'
                }
            },
            components:{
                student,
            },
            methods: {
                showName(){
                    alert(this.schoolName)
                }
            },
        })

        const hello = Vue.extend({
            template:`
            <div>
                <h2>你好,{{name}}</h2>
            </div>
            `,
            data(){
                return{
                    name:'tom'
                }
            }
        })

        const app = Vue.extend({
            template:`
            <div>
                <school></school>
                <hello></hello>
            </div>
            `,
            components:{
                school,
                hello
            }
        })

        const vm = new Vue({
            template:'<app></app>',
            el:'#root',
            //注册组件
            components:{
                app,
            }
        })

    </script>
</html>